/*-----------------------------------------------------------------------------
 * 
 *
 *-----------------------------------------------------------------------------
 */

#include "common/include/stock_update.h"
#include "server/include/stock_server_queue.h"
#include "server/include/stock_server_dgram.h"
#include "server/database/include/stock_database.h"


stock_dgram_stats_t stock_server_dgram_stats;

avl_tree *stock_server_dgram_clients;

static void 
stock_server_dgram_init()
{
    memset(&stock_server_dgram_stats, 0, sizeof(stock_dgram_stats_t));
}

void
stock_server_dgram(int server_sock)
{
    stock_update update;
    int          rc;

    stock_server_dgram_init();

    while (1) {
        rc = stock_update_recv(server_sock, &update);

        if (rc == 0) {

            rc = stock_database_filter(&update);

            if (rc != 0) {
                continue;
            }

            stock_server_enqueue(&update); 
                         
        }
    }
}

